from modules import dj
from common import PlayEntity
from businessrules import PlayBiz

def console():
    return dict() 

def play():
    if request.env.request_method == "POST":
        if request.vars.get("play_new"):
            #DJ is playing a song not in the DB 
            songName = request.vars.get('song').strip()
            artistName = request.vars.get('artist').strip()
            albumName = request.vars.get('album', 'Unknown').strip()
            description = request.vars.get("description", 'None').strip()
            songID = dj.createNewSong(songName,artistName,albumName,description)
        else:
            #not playing a new song. get song_id from request
            songID = request.vars.get("song_id")

        #TODO: get real dj ID
        DJ = 1
        play = PlayEntity.PlayEntity(DJ=DJ, songID=songID)
        PlayBiz.PlayBiz().InsertPlay(play) 

    redirect(URL('dj','console'))

